package com.pure.common.enums;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;

/**
 * 价格类型反序列化
 *
 * @author shang
 */
public class PriceTypeJsonDeserializer extends JsonDeserializer<PriceType> {
    @Override
    public PriceType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        Byte code = p.readValueAs(Byte.class);
        return PriceType.getPriceType(code);
    }
}
